package com.googlecode.grs.sensor;

import java.awt.Color;
import java.awt.Graphics;

import com.googlecode.grs.core.SimulatedSensor;
import com.googlecode.grs.environment.SimulationEnvironment;

/**
 * Models the behavior and output of the iRobot Create's builtin IR beacon
 * sensor, allowing for home base location. REDBUOY is the signal emitted when
 * the base station is on the left. GREENBUOY is the signal emitted when the
 * base station is on the right. FORCEFIELD is the signal emitted when the Robot
 * is particularly close to the homebase
 * 
 * @author ajc
 */
public class BeaconSensor extends SimulatedSensor {

	public static final int RANGE = 150;

	// private

	public BeaconSensor(SimulationEnvironment env) {
		super(env, 0, 0);// TODO constant-ize this
		// TODO Auto-generated constructor stub
	}

	@Override
	public void draw(Graphics g) {
		g.setColor(Color.RED);

		g.setColor(new Color(0.f, 1.f, 0.f, .75f));
		g.fillArc((int) (robotX() + x) - RANGE / 2, (int) (robotY() + y)
				- RANGE / 2, RANGE, RANGE, -20 + -1
				* (int) ((robotHeading() * 360 / (Math.PI * 2)) % 360), 10);

		g.setColor(new Color(1.f, 1.f, 0.f, .75f));
		g.fillArc((int) (robotX() + x) - RANGE / 2, (int) (robotY() + y)
				- RANGE / 2, RANGE, RANGE, -10 + -1
				* (int) ((robotHeading() * 360 / (Math.PI * 2)) % 360), 20);

		g.setColor(new Color(1.f, 0.f, 0.f, .75f));
		g.fillArc((int) (robotX() + x) - RANGE / 2, (int) (robotY() + y)
				- RANGE / 2, RANGE, RANGE, 10 + -1
				* (int) ((robotHeading() * 360 / (Math.PI * 2)) % 360), 10);

	}

	@Override
	public void poll() {
		// TODO Auto-generated method stub

	}

	@Override
	public void sensorStateChanged(int id, double prevData, double data) {
		// TODO Auto-generated method stub

	}

}
